package br.com.carrosvale.model.persistence;

import org.hibernate.Criteria;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import br.com.carrosvale.model.entity.Login;

@Repository
public class LoginRepository extends BaseRepository<Login>  {
	
	public Login buscarLogin( Login login ){
		Criteria criteria = createCriteria()
			.add( Restrictions.eq("login", login.getLogin()) )
			.add( Restrictions.eq("senha", login.getSenha()) );
		
		return uniqueResult(criteria);
	}
	
	@Autowired
	public void init(SessionFactory factory) {
	    setSessionFactory(factory);
	}

}